<template>
  <a-card>
    <template slot="extra">
      <a-button type="link" @click="$router.push({ name: 'AddCategory' })">一级分类</a-button>
      <a-button type="link" @click="$router.push({ name: 'AddSecondCategory' })">二级分类</a-button>
      <a-button type="link" @click="$router.push({ name: 'AddProduct' })">添加产品</a-button>
    </template>
    <a-form-model
      :model="form"
    >
      <a-form-model-item label="分类名称">
        <a-input v-model="form.name" type="text" />
      </a-form-model-item>
      <a-form-model-item>
        <a-button type="primary" @click="addCategory">添加分类</a-button>
      </a-form-model-item>
    </a-form-model>
  </a-card>
</template>

<script>
import { addCategory } from '@/api/product'

export default {
  name: 'AddCategory',
  data () {
    return {
      form: {}
    }
  },
  methods: {
    addCategory () {
      addCategory(this.form).then(res => {
        if (res.status === 0) {
          this.$message.success('添加成功')
        } else {
          this.$warning({
            title: res.msg
          })
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
